
Shader "Tools/VertexColorHelper"
{
    Properties
    {
         
    }
    SubShader
    {
        Pass
        {

            Cull Off
            Tags {"LightMode"="ForwardBase"}
        
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #include "UnityCG.cginc"
            #include "UnityLightingCommon.cginc"


            struct appdata
            {
                float4 vertex : POSITION;
                float3 normal :NORMAL;
                float2 texcoord : TEXCOORD0;
                float4 color:COLOR;
            };
            struct v2f
            {
                float2 uv : TEXCOORD0;
                fixed4 diff : COLOR0;
                float4 vertex : SV_POSITION;
            };

            v2f vert (appdata v)
            {
                v2f o;
                o.vertex = UnityObjectToClipPos(v.vertex);
                o.uv = v.texcoord;
                half3 worldNormal = UnityObjectToWorldNormal(v.normal);
                half nl = max(0, dot(worldNormal, _WorldSpaceLightPos0.xyz));
                o.diff = nl * _LightColor0;

                // the only difference from previous shader:
                // in addition to the diffuse lighting from the main light,
                // add illumination from ambient or light probes
                // ShadeSH9 function from UnityCG.cginc evaluates it,
                // using world space normal
                o.diff.rgb += 0.2;
                return o;
            }
            
     

            fixed4 frag (v2f i) : SV_Target
            {
                fixed4 col = half4(1.0,i.uv*0.5+0.5,0);// tex2D(_MainTex, i.uv);
                col *= i.diff*0.8;
                return col;
            }
            ENDCG
        }
    }
}

/*
Shader "Tools/VertexColorHelper"
{
    Properties
    {
        
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 100

        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            // make fog work
            #pragma multi_compile_fog

            #include "UnityCG.cginc"

            struct appdata
            {
                float4 vertex : POSITION;
                float3 normal :NORMAL;
                float2 uv : TEXCOORD0;
                float4 color:COLOR;
            };

            struct v2f
            {
    
                float4 color: TEXCOORD1;
                float3 worldNormal: TEXCOORD2;
                float4 vertex : SV_POSITION;
            };

          

            v2f vert (appdata v)
            {
                v2f o;
                o.vertex = UnityObjectToClipPos(v.vertex);

                half3 worldNormal = UnityObjectToWorldNormal(v.normal);
                //half nDotL =  saturate(  dot(worldNormal,normalize( half3(0,-0.5,1.0))) )+0.5;
                o.worldNormal = worldNormal;
                o.color = half4(1.0, v.uv.xy,1.0) ;
                return o;
            }

            fixed4 frag (v2f i) : SV_Target
            {
            half3 lighrDir = normalize( half3(0,-0.5,1.0));
            
            half nDotL =  saturate(  dot(normalize( i.worldNormal), lighrDir ))+0.5;
            return nDotL;
                return i.color *nDotL;
              
            }
            ENDCG
        }
    }
}
*/